'''
使用request发送get请求
'''
import requests#
base_url = 'http://192.168.2.36:8088/futureloan/mvc/api/member/'

url = base_url + 'list'

r = requests.get(url)
print(type(r))
print(r.text)
print(type(r.json))
assert r.json()['msg'] == '获取用户列表成功'
assert r.json()['code'] == '10001'
assert r.json()['status'] == 1

#get请求带参数
#1.拼接到url的后面
url = base_url + "register?mobilephone=18012335678&pwd=123456"

r = requests.get(url)
print(r.json())
assert r.json()['msg'] == '手机号码已被注册'
assert r.json()['code'] == '20110'
assert r.json()['status'] == 0

#使用params传参
canshu = {
    "mobilephone":18012345678,
    "pwd":123456
}
url = base_url + 'register'
r = requests.get(url,params=canshu)
assert r.json()['code'] == '20110'
assert r.json()['status'] == 0

#
url = "http://www.httpbin.org/get"

r = requests.get(url,params=canshu)
print(r.text)

#使用requests发送请求，"User-Agent": "python-requests/2.25.1"

head = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"
}
r = requests.get(url,params=canshu,headers = head)
print(r.text)